home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / PINBSRC.ZIP / _INTEGRI.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-02  |  7.3 KB  |  241 lines

  1. {_INTEGRI.PAS   - (c) Ansgar Scherp, Joachim Gelhaus
  2.   All rights reserved / vt'95 }
  3.  
  4. CONST
  5.   ok = True ;  fehler = False ;
  6.   esc = #27 ;  null = #0      ;
  7.   fst_sekt     = 16           ;
  8.   stdid        = 'CD001'      ;
  9.   xa_id        = 'CD-XA001'   ;
  10.   hsfs         = 'CDROM'      ;
  11.   boot_rec     = 0            ;
  12.   prim_dtyp    = 1            ;
  13.   suppl_dtyp   = 2            ;
  14.   part_dtyp    = 3            ;
  15.   vd_term      = 255          ;
  16.   d_char = [ 'A'..'Z','0'..'9','_'];
  17.  
  18. TYPE
  19.   ptr_sector = ^sector;  sector  = Array[1..2048] of Byte;
  20.   ptr_drec  = ^raw_rec;  raw_rec = Array[1..256] of Byte;
  21.   isoidtyp  = Array[1..128] of Char;  isoidptr = ^isoidtyp;
  22.   ptr_prim_vd = ^iso_p_descriptor;
  23.   vd_datime = Record
  24.     datime : Array[1..16] of Char;
  25.     gmt    : ShortInt                     { -48 .. +52}
  26.   End;
  27.   iso_p_descriptor = Record     { Primary Volume Descriptor }
  28.     VD_typ         : Byte                ;
  29.     std_id         : Array[1..5] of Char ;
  30.     vd_vers        : Byte                ;
  31.     unused1        : Byte                ;
  32.     sys_id         : Array[1..32] of Char;
  33.     vol_id         : Array[1..32] of Char;
  34.     unused8        : Array[1..8]  of Byte;
  35.     vol_spc_sizeL  : LongInt             ;
  36.     vol_spc_sizeM  : LongInt             ;
  37.     unused32       : Array[1..32] of Byte;
  38.     vol_set_sizeL  : Word                ;
  39.     vol_set_sizeM  : Word                ;
  40.     vol_seq_nrL    : Word                ;
  41.     vol_seq_nrM    : Word                ;
  42.     log_blc_sizeL  : Word                ;
  43.     log_blc_sizeM  : Word                ;
  44.     pth_tb_sizeL   : LongInt             ;
  45.     pth_tb_sizeM   : LongInt             ;
  46.     typ_L_path_tb  : LongInt             ;
  47.     opt_L_path_tb  : LongInt             ;
  48.     typ_M_path_tb  : LongInt             ;
  49.     opt_M_path_tb  : LongInt             ;
  50.     root_dir_rec   : Array[1..34] of Byte;
  51.     vol_set_id,
  52.     publ_id,
  53.     data_prep_id,
  54.     appl_id        : Array[1..128]of Char;
  55.     c_file_id      : Array[1..37] of Char;
  56.     abstr_file_id  : Array[1..37] of Char;
  57.     bibl_file_id   : Array[1..37] of Char;
  58.     vol_creat_datime,
  59.     vol_mod_datime,
  60.     vol_expi_datime,
  61.     vol_eff_datime : vd_datime           ;
  62.     file_struct_ver: Byte                ;
  63.     reserved1      : Byte                ;
  64.     app_use        : Array[1..141] of Byte;
  65.  
  66.     xa_sign        : Array[1..8] of Char ;
  67.     xa_flags       : Word                ;
  68.     startup_dir    : Array[1..8] of Char ;
  69.     reserved8      : Array[1..8] of Byte ;
  70.  
  71.     reserved1000   : Array[1051..2048] of Byte;
  72.   End;{isopdescriptor}
  73.  
  74.   boot_record = Record
  75.     vd_typ         : Byte                ;
  76.     std_id         : Array[1..5] of Char ;
  77.     vd_vers        : Byte                ;
  78.     sys_id         : Array[1..32] of Char;
  79.     boot_id        : Array[1..32] of Char;
  80.     sys_use        : Array[1..1977]of Byte;
  81.   End;{bootrecord}
  82.  
  83.   vol_partition_descriptor = Record
  84.     vd_typ         : Byte                ;
  85.     std_id         : Array[1..5] of Char ;
  86.     vd_vers        : Byte                ;
  87.     dummy          : Byte                ;
  88.     sys_id         : Array[1..32] of Char;
  89.     part_id        : Array[1..32] of Char;
  90.     part_locL      : LongInt             ;
  91.     part_locM      : LongInt             ;
  92.     sizeL          : LongInt             ;
  93.     sizeM          : LongInt             ;
  94.     reserved       : Array[1..1960]of Byte;
  95.   End;{volpartdescrpt}
  96.  
  97.   ptr_dir_rec = ^directory_record;
  98.   dr_datime = Record
  99.     datime : Array[1..6] of Byte;
  100.     gmt    : ShortInt                         { -48 .. +52}
  101.   End;
  102.   directory_record = Record
  103.     len_dr         : Byte                ;
  104.     len_ar         : Byte                ;
  105.     loc_extentL    : LongInt             ;
  106.     loc_extentM    : LongInt             ;
  107.     len_dataL      : LongInt             ;
  108.     len_dataM      : LongInt             ;
  109.     rec_datime     : dr_datime           ;
  110.     file_flags     : Byte                ;
  111.     unit_size      : Byte                ;
  112.     interl_gap_size: Byte                ;
  113.     vol_sequ_numL  : Integer             ;
  114.     vol_sequ_numM  : Integer             ;
  115.     len_fi         : Byte                ;
  116.     file_name      : Array[1..223] of Char;
  117.   End;{directoryRecord}
  118.  
  119.   ptr_xa_dir = ^xa_dir_extens;
  120.   xa_dir_extens = Record
  121.     ow_id          : Integer             ;
  122.     grp_id         : Integer             ;
  123.     attr           : Word                ;
  124.     sign           : Array[1..2] of Char ;
  125.     file_num       : Byte                ;
  126.     reserved       : Array[1..5] of Byte ;
  127.   End;{xa-Extension}
  128.  
  129.   ptr_pt_rec = ^path_table_record;
  130.   path_table_record = Record
  131.     len_di         : Byte                ;
  132.     len_ar         : Byte                ;
  133.     loc_ext        : LongInt             ;
  134.     parent_dir_num : Integer             ;
  135.     dir_name       : Array[1..32] of Char;
  136.   End;{pathtable}
  137.  
  138. VAR prim_vd : ptr_prim_vd;
  139.  
  140.  
  141. FUNCTION pstr( pvd : isoidptr; strlen : Byte ) : String;
  142. VAR sammel : String; i : Integer;
  143. Begin
  144.   sammel[0] := Char( strlen);
  145.   i := 1;
  146.   While (pvd^[i]<>null) and (i <= strlen) DO Begin
  147.     sammel[i] := pvd^[i] ;
  148.     Inc(i);
  149.   End;{While}
  150.   IF i < strlen Then sammel[0] := Char(i-1);
  151.   i := length(sammel);
  152.   While sammel[i] = ' ' Do Begin
  153.     Dec(i);
  154.     sammel[0] := Chr(i);
  155.   End;
  156.   pstr := sammel;
  157. END;{pstr}
  158.  
  159. FUNCTION btst(by, bi : Byte) : Boolean;
  160. Begin
  161.   IF Odd( by Shr bi) Then btst := True
  162.                      Else btst := False;
  163. End;
  164. FUNCTION bin(wert : LongInt; bits : Byte ) : String;
  165. VAR i : Integer; c : String[32];
  166. Begin
  167.   c := '';
  168.   For i := 1 to bits DO Begin
  169.     IF odd(wert) Then c := '1' + c
  170.                  Else c := '0' + c;
  171.     wert := wert shr 1;
  172.   End;{For}
  173.   bin := c;
  174. END;
  175.  
  176. FUNCTION lies_sekt(beginn : LongInt; s_anzahl : Integer ;
  177.                             VAR puffer : sector) : Boolean;
  178. VAR  regs : Registers;
  179. Begin
  180.   regs.ax := $1508;
  181.   regs.CX := Ord(cd_lw)-65;
  182.   regs.SI := beginn Shr 16;
  183.   regs.DI := beginn Mod 65536;
  184.   regs.DX := s_anzahl;
  185.   regs.ES := Seg(puffer);
  186.   regs.BX := Ofs(puffer);
  187.   Intr($2F, regs);
  188.   IF Odd(regs.Flags)=true Then Begin
  189.       lies_sekt := fehler;
  190.   End
  191.   Else
  192.     lies_sekt := ok;
  193. END;
  194.  
  195.  
  196. FUNCTION cd_iso_test(VAR prim_vd : ptr_prim_vd) : Boolean ;
  197. Begin
  198.   cd_iso_test := False;
  199.   cd_iso := false;
  200.   cd_name := '';
  201.   IF lies_sekt(fst_sekt, 1, sector(prim_vd^)) = ok Then Begin
  202.     IF pstr(@prim_vd^.std_id, 5) = stdid Then Begin
  203.       cd_name := pstr(@prim_vd^.vol_id,32);
  204.       cd_iso := true; { ISO-9660-CD-ROM }
  205.       cd_iso_test := True;
  206.     End{If stid}
  207.   End;{IFok}
  208. END;{cd-iso-test}
  209.  
  210. procedure CheckCDROM;
  211. var buffer:string[20];
  212.     regs:registers;
  213.     hilfsb:word;
  214. begin
  215.  
  216.   regs.ax:=$150D;
  217.   regs.es:=seg(buffer[1]);
  218.   regs.bx:=ofs(buffer[1]);
  219.   intr($2F,regs);
  220.   cd_lw:=chr(ord(buffer[1])+65);
  221.  
  222.   path:=paramstr(0);
  223.   act_lw:=path[1];
  224.   hilfsb:=0;
  225.   while pos('\',copy(path,length(path)-hilfsb,1))=0 do inc(hilfsb);
  226.   path:=(copy(path,1,length(path)-hilfsb-1));
  227.   chDir(path);
  228.  
  229.   New(prim_vd);
  230.   if cd_iso_test(prim_vd) = ok then begin end;
  231.   Dispose(prim_vd);
  232.   writeln('CD-ROM-DRIVE   :', cd_lw);
  233.   writeln('CD-ROM-NAME    :', cd_name);
  234.   writeln('CD-ROM-ISO9660 :', cd_iso);
  235.   writeln('CURRENT_DRIVE  :', act_lw);
  236.  
  237. end;
  238.  
  239.  
  240.  
  241.